public with sharing class Cald_DetailPlanEligibilityVF
{
    private final Callidus_Plan__c[] plan = new Callidus_Plan__c[1];
    public Callidus_Plan_Role__c[] planRole {get; set;}

    public Cald_DetailPlanEligibilityVF(ApexPages.StandardController myController)
    {
        this.plan[0] = (Callidus_Plan__c)myController.getRecord();
        planRoleList();
    }
    
    public void planRoleList()
    {
        planRole = [select Id, Description__c, RoleTitle__c from Callidus_Plan_Role__c where Plan__c = :plan[0].id];
        if(planRole.size() == 0) 
            planRole = null;
    }

    static testMethod void testCald_DetailPlanEligibilityVF()
    {
        PageReference pg = Page.Cald_DetailPlanEligibilty;
        Test.setCurrentPage(pg);
        
        Callidus_Plan__c planObj = new Callidus_Plan__c(Name = 'Test', Start_Date__c = Date.today(), End_Date__c = (Date.today() + 100), Quota__c = 1000000);
        insert planObj;
		List<Callidus_Plan__c> tPlan = [select Name from Callidus_Plan__c where id = :planObj.id];
		for(Callidus_Plan__c p:tPlan)
		{
			System.assertEquals('Test', p.Name);
		}
        
        Callidus_Plan_Role__c pr = new Callidus_Plan_Role__c(plan__c = planObj.id);
        insert pr;
		List<Callidus_Plan_Role__c> tPlanRole = [select Plan__c from Callidus_Plan_Role__c where id = :pr.id];
		for(Callidus_Plan_Role__c p:tPlanRole)
		{
			System.assertEquals(planObj.id, p.Plan__c);
		}
        
        ApexPages.StandardController mc = new Apexpages.Standardcontroller(planObj);
        Cald_DetailPlanEligibilityVF dp = new Cald_DetailPlanEligibilityVF(mc);
        delete pr;
        system.assertEquals(planObj.id, pr.Plan__c);
        Cald_DetailPlanEligibilityVF dp1 = new Cald_DetailPlanEligibilityVF(mc);
    }
}